﻿// ***********************************************************************
// Assembly         : MVC4Portal
// Author           : LJO+01 (Laurent Jordi)
// Created          : 06-05-2013
// Last Modified By : LJO+01 (Laurent Jordi)
// Last Modified On : 06-05-2013
// ***********************************************************************
// <copyright file="WebApiConfig.cs" company="Copyright © Innovacall 2011">
//     Copyright (c) Copyright © Innovacall 2011. All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************
using System.Web.Http;
using System.Web.Http.OData.Builder;
using InnovaApp.Layers.DomainLayer;
using Microsoft.Data.Edm;

namespace InnovaApp.Portals.MVC4Portal.App_Start
{
    /// <summary>
    /// Class WebApiConfig
    /// </summary>
    public class WebApiConfig
    {
        /// <summary>
        /// Registers the specified config.
        /// </summary>
        /// <param name="config">The config.</param>
        public static void Register(HttpConfiguration config)
        {
            ODataConventionModelBuilder modelBuilder = new ODataConventionModelBuilder();
            modelBuilder.EntitySet<v_Contacts>("contacts");
            IEdmModel model = modelBuilder.GetEdmModel();

            config.Routes.MapODataRoute(
                routeName: "OData",
                routePrefix: "odata",
                model: model
            );

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{language}/{id}",
                defaults: new { language = string.Empty, id = RouteParameter.Optional }
            );

            //config.Routes.MapHttpRoute(
            //name: "CountryApi",
            //routeTemplate: "api/country/{action}",
            //defaults: new { controller = "CountryApi" }
            //);
        }
    }
}
